package com.homedo.odin.solution.controller.wap;

import com.homedo.core.common.base.controller.BaseController;
import com.homedo.core.common.base.dto.ResultData;
import com.homedo.odin.solution.contract.wap.SolutionAppDetailResp;
import com.homedo.odin.solution.contract.wap.SolutionAppIndexResp;
import com.homedo.odin.solution.contract.wap.SolutionListResp;
import com.homedo.odin.solution.service.bizservice.wap.WapSolutionsBizService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zhaoxudong
 * @date: 2018/3/27 17:41
 * @Description:
 */
@Api(description = "方案", tags = {"Solution"}, produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequestMapping("/wap/solutions")
public class WapSolutionsController extends BaseController<WapSolutionsBizService> {

    @ApiOperation(value = "M站_获取方案列表", notes = "M站_获取方案列表", response = SolutionListResp.class)
    @GetMapping
    public ResultData querySolutionsByParams(
            @ApiParam(value = "方案类型1:系统方案 2:品牌方案", required = false) @RequestParam(value = "solutionType", required = false) Integer solutionType,
            @ApiParam(value = "品牌id", required = false) @RequestParam(value = "brandId", required = false) Integer brandId,
            @ApiParam(value = "系统属性(一级系统属性)", required = false) @RequestParam(value = "sysAttr", required = false) Integer sysAttr,
            @ApiParam(value = "建筑业态", required = false) @RequestParam(value = "buildingType", required = false) Integer buildingType,
            @ApiParam(value = "当前页码", required = true) @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @ApiParam(value = "每页记录数", required = true) @RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize) {
        SolutionListResp resp = baseService
                .querySolutionsByParams(solutionType, brandId, sysAttr, buildingType, pageNum, pageSize);
        return ResultData.newInstance(resp);
    }

    @ApiOperation(value = "M站_获取方案详情", notes = "M站_获取方案详情", response = SolutionAppDetailResp.class)
    @GetMapping("{solutionId}")
    public ResultData solutionDetail(@ApiParam("方案id") @PathVariable("solutionId") Long solutionId) {
        SolutionAppDetailResp resp = baseService.solutionDetail(solutionId);
        return ResultData.newInstance(resp);
    }

    @ApiOperation(value = "M站_获取品牌主方案列表", notes = "M站_获取品牌主方案列表", response = SolutionListResp.class)
    @GetMapping("/{uid}/list")
    public ResultData solutionListForBrandFirm(@ApiParam("品牌主id") @PathVariable("uid") Integer uid,
            @ApiParam("当前页码") @RequestParam("pageNum") Integer pageNum,
            @ApiParam("每页数量") @RequestParam("pageSize") Integer pageSize) {
        SolutionListResp resp = baseService.solutionListForBrandFirm(uid, pageNum, pageSize);
        return ResultData.newInstance(resp);
    }

    @ApiOperation(value = "M站_获取热榜方案图片", notes = "M站_获取热榜方案图片", response = SolutionAppIndexResp.class)
    @GetMapping("/pics")
    public ResultData hotPics() {
        SolutionAppIndexResp resp = baseService.hotPics();
        return ResultData.newInstance(resp);
    }

    @ApiOperation(value = "M站_获取方案热榜列表", notes = "M站_获取方案热榜列表", response = SolutionListResp.class)
    @GetMapping("/hot")
    public ResultData hotList(@ApiParam("类型 1：昨日热榜 2：周热榜 3：月热榜") @RequestParam("type") Integer type,
            @RequestParam(value = "number", defaultValue = "10") Integer number) {
        SolutionListResp resp = baseService.hotList(type, number);
        return ResultData.newInstance(resp);
    }
}
